package SqlService;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.TimerTask;

public class LTC {
	private Connection sqlGo;
	public LTC()
	{
		Sql sql = new Sql();
		sqlGo = sql.getCon();
	}
	public boolean LTC2()
	{		
		try{
			PreparedStatement sqlReady;
			String query="insert into ltc(mac,times) select mac lastmac,max(times) lasttimes from wifidata group by mac on duplicate key update ltc.times = (select max(wifidata.times) lasttimes from ltc,wifidata where wifidata.ranges < 200 group by wifidata.mac having wifidata.mac=ltc.mac);";
			sqlReady = sqlGo.prepareStatement(query);
			if (sqlReady.executeUpdate() == 0)
			{
				System.out.println("LTC执行失败");
				return false;
			}
			System.out.println("LTC功能执行成功");
			return true;
		}
		catch(SQLException e){
			System.out.println("LTC运行出错!");
			e.printStackTrace();
			return false;
		}
	}
}
